#include<bits/stdc++.h>
using namespace std;
int main(){
    //freopen("in.txt","r",stdin);

    map<string,int>m;
    string speeach;
    getline(cin,speeach);
    string t="";
    for(int i=0;i<speeach.length();i++){
        if(isalnum(speeach[i])){
            if(isupper(speeach[i])){speeach[i]=tolower(speeach[i]);}
            t+=speeach[i];
        }
        if((!isalnum(speeach[i]) && t!="")||i==speeach.length()-1){
            m[t]++;
            t="";
        }
    }
    int maxn=0;
    string res;
    for(auto it=m.begin();it!=m.end();it++){
        if(it->second>maxn){
            maxn=it->second;
            res=it->first;
        }
        else if(it->second==maxn && it->first<res){
            res=it->first;
        }
    }
    cout<<res<<" "<<maxn<<endl;
}
